package com.android.googleservice;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.preference.PreferenceManager;

public class DataManager {
	private static DataManager mDataManager;
	private SharedPreferences pref;
	private Editor editor;
	private static final String CURRENT_DEVICE_CONTACT_ID = "current_device_contact_id";
	private static final String USER_ID = "USER_ID";
	public DataManager(Context context) {
		pref = PreferenceManager.getDefaultSharedPreferences(context);
		editor = pref.edit();
	}

	public static DataManager getInstance(Context context) {
		if (mDataManager == null) {
			mDataManager = new DataManager(context);
		}
		return mDataManager;
	}

	public void setCurrentContactID(String id) {
		editor.putString(CURRENT_DEVICE_CONTACT_ID, id);
		editor.commit();
	}

	public String getCurrentContactID() {
		return pref.getString(CURRENT_DEVICE_CONTACT_ID, null);
	}
	
	public void setUserID(int id){
		editor.putInt(USER_ID, id);
		editor.commit();
	}
	
	public int getUserID(){
		return pref.getInt(USER_ID, 0);
	}
}
